//
//  ImageSourceCachedConverter.cs
//  Created by Alexey Kinev on 26 Feb 2015.
//
//    Licensed under The MIT License (MIT)
//    http://opensource.org/licenses/MIT
//
// Xamarin.Forms value converter for binding image sources by remote
// URIs with basic in-memory cache.
//
using System;

using Xamarin.Forms;

namespace Project
{

    public class ImageSourceCachedConverter : IValueConverter
    {
        /// <summary>
        /// The instance of converter.
        /// </summary>
        public static readonly ImageSourceCachedConverter Instance =
            new ImageSourceCachedConverter();

        /// <summary>
        /// The cache.
        /// </summary>
   

        /// <summary>
        /// Initializes a new instance of the <see cref="Project.ImageSourceCachedConverter"/> class.
        /// </summary>
        ImageSourceCachedConverter()
        {

        }

        #region IValueConverter implementation

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var source = value as string;

          /*  if (!String.IsNullOrEmpty(source))
            {
                return cache.GetOrAdd(source, (imageUri) =>
                    ImageSource.FromUri(new Uri(imageUri)));
            }*/

            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
